-- -*- mode: lua; -*-

conky.config = {
	out_to_x = false,
	background = false,
	cpu_avg_samples = 2,
	net_avg_samples = 2,
	no_buffers = true,
	out_to_console = true,
	out_to_stderr = false,
	extra_newline = false,
	update_interval = 1.0,
	uppercase = false,
	use_spacer = left,
	times_in_seconds = true,
};

-- Colors are in dzen2 format.
conky.text =
[[^fg(grey)${time %a %d %b} \
       \
^fg(grey)CPU:^fg(DeepSkyBlue)$cpu% \
^fg(grey)RAM:^fg(DeepSkyBlue)${if_match ${to_bytes $memeasyfree} < 536870912}^fg(Red)${endif}$memperc% \
^fg(grey)↓^fg(DeepSkyBlue)${downspeedf ${gw_iface}} \
^fg(grey)↑^fg(DeepSkyBlue)${upspeedf ${gw_iface}} \
${if_match "${exec pactl list sinks | awk '/^\tMute:/ {print $2;exit}'}" == "no"}^fg(grey)♪^fg(DeepSkyBlue)${exec pactl list sinks | awk '/^\tVolume:/ {print $5;exit}'}${endif} \
${if_match $battery_percent != 0}^fg(grey)⚡^fg(DeepSkyBlue)${if_match ${battery_time} <= 600}^fg(Red)${endif}${battery_short}: ${format_time ${battery_time} "(\dd )(\hh )\mmin"} ${endif}\
${if_match ${to_bytes ${diskio nvme0n1}} > 1048576}^fg(grey)nvme0n1:^fg(DeepSkyBlue)${diskio nvme0n1}${endif} \
${if_match ${to_bytes ${diskio sda}} > 1048576}^fg(grey)sda:^fg(DeepSkyBlue)${diskio sda}${endif} \
${if_match ${to_bytes ${diskio sdb}} > 1048576}^fg(grey)sdb:^fg(DeepSkyBlue)${diskio sdb}${endif} \
${if_match ${to_bytes ${diskio sdc}} > 1048576}^fg(grey)sdc:^fg(DeepSkyBlue)${diskio sdc}${endif} \
${if_match ${to_bytes ${fs_free /}} < 1073741824}^fg(grey)/:^fg(Red)${fs_free /}${endif} \
${if_match ${to_bytes ${fs_free /home}} < 1073741824}^fg(grey)/home:^fg(Red)${fs_free /home}${endif} \
]]

-- mu unread emails: This is treacherously distracting...
-- ${if_existing .mu/}^fg(grey)✉^fg(DeepSkyBlue)${execi 30 mu find --nocolor --sortfield=d --maxnum=500 flag:unread AND NOT flag:trashed 2>/dev/null | wc -l} ${endif}\
-- Unread mail with native 'new_mails' does not seem to support totals.
-- Change color when e-mails are not 0?

-- TODO: Emms current track:
-- ${if_match "${execi 5 emacsclient -e '(and (fboundp (quote emms-playlist-current-selected-track)) (emms-playlist-current-selected-track) (emms-track-description (emms-playlist-current-selected-track)))'}" != "nil"}^fg(grey)♪^fg(DeepSkyBlue)${execi 5 emacsclient -e '(emms-track-description (emms-playlist-current-selected-track))' | tr -d '"'}${endif} \
-- Above line works but polling interferes with bindings (Emacs echoes '<t>' on keypresses).

-- TODO: Conditional display of network, sound.
-- Probably need $lua+$eval for most of the TODOs.
-- TODO: Calling pactl when pulseaudio is not running will fire it up, which can
-- lead to a race condition when relogging: 4 pulseaudio processes will end up
-- running.
